import { Type } from 'class-transformer';
import { IsNotEmpty } from 'class-validator';
import { BaseClass } from '../base';

export class User extends BaseClass {
  @IsNotEmpty({ message: '用户id不能为空！' })
  @Type(() => String)
  public userId: string;

  @IsNotEmpty({ message: '用户昵称不能为空！' })
  @Type(() => String)
  public nickname: string;

  @IsNotEmpty({ message: '用户头像不能为空！' })
  @Type(() => String)
  public avatar: string;

  @IsNotEmpty({ message: '用户扫码登录ip地址不能为空！' })
  @Type(() => Array)
  public ipAddr: Array<string>;

  @IsNotEmpty({ message: '用户注册时间不能为空！' })
  @Type(() => String)
  public registerDate: string;

  public static transformerThis(m: {}) {
    return super.plainClass(User, m);
  }
}
